//
//  BaseTableViewController.swift
//  jackWu
//
//  Created by Lewhaming on 2016/11/22.
//  Copyright © 2016年 IQ. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {
    var isLogin = true
    var visitorView : VisitorView?
    override func loadView() {
        //判断用户是否登录， 如果没有登录就显示访客界面
        
        isLogin ? super.loadView():setupVisionView()
    }
    
    private func setupVisionView(){
        visitorView = VisitorView.visitorView()
        view = visitorView
//        visitorView?.delegate = self
        visitorView?.regButton.addTarget(self, action:#selector(regBtnClicked(btn:)), for: UIControlEvents.touchUpInside)
        visitorView?.loginButton.addTarget(self, action:#selector(loginBtnClicked(btn:)), for: UIControlEvents.touchUpInside)
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.plain, target: self, action: #selector(regBtnClicked(btn:)))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.plain, target: self, action: #selector(loginBtnClicked(btn:)))
    }
    
    @objc private func regBtnClicked(btn : UIButton){
        IQLog(message: "__")
    }
    
    @objc private func loginBtnClicked(btn : UIButton){
        IQLog(message: "__")
    }
}

//extension BaseTableViewController : VisitorViewDelegate{
//    func visitorViewDidClickLoginBtn(visitor:VisitorView){
//        IQLog(message: "登录")
//    }
//    
//    func visitorViewDidClickRegisterBtn(visitor:VisitorView){
//        IQLog(message: "注册")
//    }
//    
//}

